const CracoLessPlugin = require('craco-less');
const CracoAntDesignPlugin = require('craco-antd');
const path = require('path');
const pathResolve = (pathUrl) => path.join(__dirname, pathUrl);

module.exports = {
	webpack: {
		alias: {
			'@@': pathResolve('.'),
			'@': pathResolve('src'),
			'@assets': pathResolve('src/assets'),
			'@common': pathResolve('src/common'),
			'@components': pathResolve('src/components'),
			'@hooks': pathResolve('src/hooks'),
			'@pages': pathResolve('src/pages'),
			'@store': pathResolve('src/store'),
			'@utils': pathResolve('src/utils')
		}
	},
	eslint: {
		enable: false /* (default value) */,
		mode: 'extends' /* (default value) */ || 'file',
		configure: {
			/* Any eslint configuration options: https://eslint.org/docs/user-guide/configuring */
		},
		// 配置全局变量
		globals: {
			TCPlayer: 'readonly'
		}
		// configure: (eslintConfig, { env, paths }) => { return eslintConfig; },
		// pluginOptions: { /* Any eslint plugin configuration options: https://github.com/webpack-contrib/eslint-webpack-plugin#options. */ },
		// pluginOptions: (eslintOptions, { env, paths }) => { return eslintOptions; }
	},
	plugins: [
		// ts 采用这种方式
		// {
		// 	plugin: CracoAntDesignPlugin,
		// 	options: {
		// 		// customizeTheme: {
		// 		// 	'@primary-color': '#1DA57A'
		// 		// }
		// 	}
		// },
		{
			plugin: CracoLessPlugin,
			options: {
				lessLoaderOptions: {
					lessOptions: {
						// modifyVars: { '@primary-color': '#1DA57A' },
						javascriptEnabled: true
					}
				}
			}
		}
	],
	babel: {
		// 支持装饰器模式语法
		plugins: [ [ '@babel/plugin-proposal-decorators', { legacy: true } ] ]
	},
	//  开发服务
	devServer: {
		proxy: {
			// 代理地址
			'/api': {
				// target: 'http://119.91.196.231:7001/',
				target: 'http://119.91.196.231/mock/',
				changeOrigin: true,
				pathRewrite: {
					'^/api': ''
				}
			}
		}
	}
};
